package com.sh.data.engine.web.webapi.controller.login;

import com.sh.data.engine.application.service.login.LoginApplicationService;
import com.sh.data.engine.domain.annotation.LogExecution;
import com.sh.data.engine.domain.annotation.userlog.Business;
import com.sh.data.engine.domain.annotation.userlog.EngineOperation;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * @author: mengzheng.mhc
 * @date: 2024/8/8 16:48
 */
@Validated
@RestController
@RequestMapping("/auth")
@Tag(name = "用户登录", description = "用户登录相关API")
public class LoginController {

    @Autowired
    private LoginApplicationService loginApplicationService;

    @PostMapping("logout")
    @Operation(summary = "登出接口", description = "退出登入")
    @LogExecution(operation = EngineOperation.LOGOUT, business = Business.注销)
    public void logout(HttpServletRequest request, HttpServletResponse response) throws IOException {
        loginApplicationService.logout(request, response);
    }
}
